<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1" action="${systemctx}/sample/saveSample.web" method="post">
	<div class="pageMain">
		<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request, "systemmanage.storemanagement.title") %><span></span>
		<%=MessageResourcesUtils.getMessage(request, "dailyoperation.messageSwitchmanage.manage.title") %><span></span>
		<%=MessageResourcesUtils.getMessage(request, "dailyoperation.messageSwitchmanage.title") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storecode") %></label>
						<span>${storeEntity.number}
							<input type="hidden" id="storeid" name="storeid" value="${storeid}"/>
						</span>
					</li>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storename") %></label>
						<span>${storeEntity.name}</span>
					</li>
					
				</ul>
			</div>	
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butStart" name="butStart" value="<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.button.start") %>" />
			<input type="button" class="btn btn-default" id="butStop" name="butStop" value="<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.button.stop") %>" />
			<input type="button" class="btn btn-default" id="butReturn" name="butReturn" value='<%=MessageResourcesUtils.getMessage(request, "common.button.back") %>' />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
$(document).ready(function(){	
	$('#datagrid').issdatagrid({
		formid : 'form1',
		title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.messageSwitchmanage.title.list")%>',
		width : 'auto',
		nowrap : true,
		autoRowHeight : false,
		singleSelect : false,
		striped : true,
		url : '${systemctx}/dailyoperation/storemessageSwitch/queryMessageSwitchDetailManageListInfoDataGrid.json',
		sortName: 'modifytime',
		sortOrder: 'desc',
		remoteSort : true,
		idField : 'id',
		pagination : true,
		rownumbers : true,
		showFooter : true,
		queryParams:$('#form1').serializeObject(),
		columns : [[ 
			 {field:'ck', checkbox:true},
			 {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.messageSwitchmanage.column.switchtype")%>',field : 'smstype',sortable : true,align : 'left',width:190}, 
			 {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.messageSwitchmanage.column.switchstatus")%>',field : 'isswitchname',sortable : true,align : 'left',width:190}, 
             {field : 'id',hidden : true}
           ]],
		onLoadSuccess : function(data) {

		}
	});
	$("#butReturn").click(function(){
		parent.document.location.reload();
	    $.fn.closeIssWindow();
	});
	$('#butStart').click(function(){
		var data=$('#datagrid').datagrid('getChecked');
		if(data!=null && data.length>0 && data.length != 0){
			var ids="";
			for(var i=0;i<data.length;i++){
				ids=data[i].id+";"+ids;
			}
			if (ids != '') {
				ids = ids.substring(0,ids.length-1);
			}
			if(confirm('<%=MessageResourcesUtils.getMessage(request,"dailyoperation.storechargemanage.alert.confirmstart")%>')){
				// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/dailyoperation/storemessageSwitch/batchStartDetailInfo.json?status=1&ids='+ids,
				    dataType: 'json',
				    success: function(data) {
				    	//关闭执行...
						closeSending();
				    	if(data.messagetype == 1){
				    		alert(data.message);
				    		$('#datagrid').datagrid('reload',$('#form1').serializeObject());
							$('#datagrid').datagrid('clearSelections');
				    	}else {
				    		alert(data.message);
				    		return;
				    	}
				    }
				});
			}
		}else{
			alert('<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.alert.warning")%>');
			return;
		}
	});
	$('#butStop').click(function(){
		var data=$('#datagrid').datagrid('getChecked');
		if(data!=null && data.length>0 && data.length != 0){
			var ids="";
			for(var i=0;i<data.length;i++){
				ids=data[i].id+";"+ids;
			}
			if (ids != '') {
				ids = ids.substring(0,ids.length-1);
			}
			if(confirm('<%=MessageResourcesUtils.getMessage(request,"dailyoperation.storechargemanage.alert.confirmstop")%>')){
				// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/dailyoperation/storemessageSwitch/batchStopDetailInfo.json?status=2&ids='+ids,
				    dataType: 'json',
				    success: function(data) {
				    	//关闭执行...
						closeSending();
				    	if(data.messagetype == 1){
				    		alert(data.message);
				    		$('#datagrid').datagrid('reload',$('#form1').serializeObject());
							$('#datagrid').datagrid('clearSelections');
				    	}else {
				    		alert(data.message);
				    		return;
				    	}
				    }
				});
			}
		}else{
			alert('<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.alert.warning")%>');
			return;
		}
	});	
});
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>